authApp.value('page','apply_apply_list'); 

authApp.controller("applyListController",function($scope,$http,page,$chineseNum,$getQueryString,Upload, $timeout,$sce,$cookieStore,$cookies){
	
	$scope.isAddM=true;
	$scope.isUpload=false;
	$scope.schoolId=$getQueryString("pid");
	var requestJson={'pageNumber':'0','pageSize':'10','schoolid':$scope.schoolId,'type':'0'};
	$scope.zpbgPath="";
	$scope.jyfbPath="";
	$scope.zzhbPath="";
	$scope.zyzzPath="";
	$scope.isUpload1=true;
	$scope.isUpload2=true;
	$scope.isUpload3=true;
	$scope.isUpload4=true;
	
	$http({
		method:'get',
		url:apis.queryApplyFileBySchoolId1,
		params:{'schoolid':$scope.schoolId},
	}).success(function(response){
		$scope.zpbg=$sce.trustAsHtml(response.data.selfEvaluationFilename);
		if(undefined==$scope.zpbg)
			$scope.isUpload1=false;
		$scope.jyfb=$sce.trustAsHtml(response.data.employmentDistributionFilename);
		if(undefined==$scope.jyfb)
			$scope.isUpload2=false;
		$scope.zzhb=$sce.trustAsHtml(response.data.specialtyConstructionFilename);
		if(undefined==$scope.zzhb)
			$scope.isUpload3=false;
		$scope.zyzz=$sce.trustAsHtml(response.data.supportingMaterialsFilename);
		if(undefined==$scope.zyzz)
			$scope.isUpload4=false;
		$scope.zpbgPath=response.data.selfEvaluationFilepath;
		$scope.jyfbPath=response.data.employmentDistributionFilepath;
		$scope.zzhbPath=response.data.specialtyConstructionFilepath;
		$scope.zyzzPath=response.data.supportingMaterialsFilepath;
		$scope.zpbgN=response.data.selfEvaluationFilename;
		$scope.jyfbN=response.data.employmentDistributionFilename;
		$scope.zzhbN=response.data.specialtyConstructionFilename;
		$scope.zyzzN=response.data.supportingMaterialsFilename;
		$scope.pid=response.data.pid;
	})
	
	$scope.getAML=function(){
		$http({
			method:'post',
			url:apis.queryItem,
			data:requestJson,
		}).success(function(response){
			if(response.code=="000000"){
				$scope.list=response.data.data;
				angular.forEach($scope.list,function(data,index,array){
					data.chindexNum=$chineseNum(data.number);
				})
			}else{
				alert(response.errorMsg);
			}
		}).error(function(){
			alert("服务器打瞌睡了，请稍等！");
		})
	}
	//alert($getQueryString("pid"));
	$scope.getAuthInfo=function(){
		$http({
			method:'get',
			url:apis.queryAuthSchoolInfo1,
			params:{'schoolid':$scope.schoolId},
		}).success(function(response){
			if(response.code=="000000"){
				$scope.state=response.data.state;
				if($scope.state=="1"){
					$scope.isUpload=true;
				}
			}else{
				alert(response.errorMsg);
			}
		}).error(function(){
			alert("服务器打瞌睡了，请稍等！");
		})
	}
	
	$scope.uploadAll=function(){			
		if(window.confirm("提交认证申请之前请确认认证申请数据是否填写完成，提交认证申请之后将不能修改！")){
			$http({
				method:'get',
				url:apis.submitApplyFile,
				params:{},
			}).success(function(response){
				if(response.code=="700006"){
					alert("提交认证申请成功！");
					setTimeout(location.reload(),100); 
				}else{
					alert(response.errorMsg);
				}	
			})
		}		
	}
	
	
	$scope.turnTo=function(pid){
		location.href="basic_apply_auth.html?pid="+pid+"&state="+$scope.state+"&schoolId="+$scope.schoolId;
	}
	
	$scope.turnToDownLoad=function(number){
		if(window.confirm("是否确定下载 ？")){
			location.href=apis.downloadApplyFile+"?pid="+$scope.pid+"&number="+number;
		}
	}
	
	$scope.getAuthInfo();
	$scope.getAML();
})